home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / communic / pcmail / aux_ / detab.c next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  1.2 KB  |  55 lines

  1. /*++
  2.  
  3. /* NAME
  4.  
  5. /*    detab 1
  6.  
  7. /* SUMMARY
  8.  
  9. /*    expand tabs to blanks
  10.  
  11. /* PROJECT
  12.  
  13. /*    sdetools
  14.  
  15. /* SYNOPSIS
  16.  
  17. /*    detab
  18.  
  19. /* DESCRIPTION
  20.  
  21. /*    Detab is a filter that expands tab stops in its standard input
  22.  
  23. /*    to blanks. A tab stop distance of eight blanks is assumed.
  24.  
  25. /* BUGS
  26.  
  27. /*    This program does not handle backspaces.
  28.  
  29. /*
  30.  
  31. /*    Should be a standard utility, but different versions of UNIX
  32.  
  33. /*    disagree on names or options.
  34.  
  35. /* AUTHOR(S)
  36.  
  37. /*    Wietse Venema
  38.  
  39. /*    Eindhoven University of Technology
  40.  
  41. /*    Department of Mathematics and Computer Science
  42.  
  43. /*    Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  44.  
  45. /* CREATION DATE
  46.  
  47. /*    Sep 14 1985
  48.  
  49. /* LAST MODIFICATION
  50.  
  51. /*    10/18/89 21:52:21
  52.  
  53. /* VERSION/RELEASE
  54.  
  55. /*    1.4
  56.  
  57. /*--*/
  58.  
  59.  
  60.  
  61. #include <stdio.h>
  62.  
  63.  
  64.  
  65. static char sccsid[] = "@(#) detab.c 1.4 10/18/89 21:52:21";
  66.  
  67.  
  68.  
  69. main()
  70.  
  71. {
  72.  
  73.     register int c;        /* character buffer */
  74.  
  75.     register int ccount = 0;    /* nr of characters printed on current line */
  76.  
  77.  
  78.  
  79.     while ((c = getchar()) != EOF) {
  80.  
  81.     switch (c) {
  82.  
  83.         case '\r':
  84.  
  85.         case '\n':  putchar(c);
  86.  
  87.             ccount = 0;
  88.  
  89.             break;
  90.  
  91.         case '\t':  do { putchar(' '); } while (++ccount & 7);
  92.  
  93.             break;
  94.  
  95.         default:    putchar(c);
  96.  
  97.             ccount++;
  98.  
  99.             break;
  100.  
  101.     }
  102.  
  103.     }
  104.  
  105.     exit(0);
  106.  
  107. }
  108.  
  109.